*** add location here
cd...

log using "appendixresults.txt", replace

use "prepared_data.dta", clear


keep if inpartyincluded==1
drop if party==idvotecat
drop if party==1&treat3==3 // drop ÖVP evaluation from SPÖ-FPÖ treatment
drop if party==2&treat3==2 // drop SPÖ evaluation from ÖVP-FPÖ treatment
drop if party==3&treat3==1 // drop FPÖ evaluation from SPÖ-ÖVP treatment


*** Appendix D: Balance test
table1, by(Gruppe) vars(male bin \ edu5cats cat \ region cat \ soph conts \ idstrength_sum conts \ age conts) ///
                format(%2.1f) saving(balancetest_replication.xls, replace)


*** Appendix I1: Graph for each partyid - outparty combination

local controls " responseorder"

regress partylike i.treat_stack_v2##i.indic  `controls', cluster(U0)
margins if indic==1, dydx(treat_stack_v2) post
estimates store m1_like
regress partylike i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if indic==2, dydx(treat_stack_v2) post
estimates store m2_like
regress partylike i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if indic==3, dydx(treat_stack_v2) post
estimates store m3_like
regress partylike i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if indic==4, dydx(treat_stack_v2) post
estimates store m4_like
regress partylike i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if indic==5, dydx(treat_stack_v2) post
estimates store m5_like
regress partylike i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if indic==6, dydx(treat_stack_v2) post
estimates store m6_like


regress partysocdist i.treat_stack_v2 i.indic   `controls' , cluster(U0)
margins, dydx(treat_stack_v2) post
estimates store m0_socdist
regress partysocdist i.treat_stack_v2##i.indic  `controls', cluster(U0)
margins if indic==1, dydx(treat_stack_v2) post
estimates store m1_socdist
regress partysocdist i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if indic==2, dydx(treat_stack_v2) post
estimates store m2_socdist
regress partysocdist i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if indic==3, dydx(treat_stack_v2) post
estimates store m3_socdist
regress partysocdist i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if indic==4, dydx(treat_stack_v2) post
estimates store m4_socdist
regress partysocdist i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if indic==5, dydx(treat_stack_v2) post
estimates store m5_socdist
regress partysocdist i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if indic==6, dydx(treat_stack_v2) post
estimates store m6_socdist


regress partylike_index i.treat_stack_v2 i.indic    `controls' , cluster(U0)
margins, dydx(treat_stack_v2) post
estimates store m0
sum partylike_index if e(sample)
regress partylike_index i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if indic==1, dydx(treat_stack_v2) post
estimates store m1
regress partylike_index i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if indic==2, dydx(treat_stack_v2) post
estimates store m2
regress partylike_index i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if indic==3, dydx(treat_stack_v2) post
estimates store m3
regress partylike_index i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if indic==4, dydx(treat_stack_v2) post
estimates store m4
regress partylike_index i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if indic==5, dydx(treat_stack_v2) post
estimates store m5
regress partylike_index i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if indic==6, dydx(treat_stack_v2) post
estimates store m6

sum partylike_index if e(sample)


 
  coefplot m1 m1_like m1_socdist m2 m2_like m2_socdist m3 m3_like m3_socdist ///
  m4 m4_like m4_socdist m5 m5_like m5_socdist m6 m6_like m6_socdist, ///
xline(0, lcolor(red) lpattern(dot)) yline(0.69, lpattern(dash) lcolor(black) ) ///
mcolor(black) ciopts(color(gs6 black )) ///
 yline(.84, lpattern(dash) lcolor(black) ) ///
 yline(1, lpattern(dash) lcolor(black) ) ///
  yline(1.16, lpattern(dash) lcolor(black) ) ///
  yline(1.32, lpattern(dash) lcolor(black) ) ///
/// title("Effect of coalition signals on affective distance") 
levels(95 90)  legend(off) msymbol(O)  xscale(range(-2.5 1.5))  ///
xtitle("<<< less affective distance || more affective distance >>>", size(small)) ///
 ylabel(0.56 "Index" 0.61 "Like-Dislike" 0.66 "Social Distance"  ///
 0.71 "Index" 0.76 "Like-Dislike" 0.81 "Social Distance"  ///
 0.86 "Index" 0.91 "Like-Dislike" 0.96 "Social Distance" ///
 1.02 "Index" 1.07 "Like-Dislike" 1.12 "Social Distance" ///
 1.18 "Index" 1.23 "Like-Dislike" 1.28 "Social Distance" ///
 1.34 "Index" 1.39 "Like-Dislike" 1.44 "Social Distance") yscale(range(0.5 1.5))  ///
 text(0.62 -2 "ÖVP by SPÖ") text(.76 -2 "ÖVP by FPÖ") text(0.92 -2 "SPÖ by ÖVP") ///
 text(1.08 -2 "SPÖ by FPÖ") text(1.24 -2 " FPÖ by ÖVP") text(1.39 -2 "FPÖ by SPÖ") ///
 scheme(plotplain) title("Effect by coalition partner and in-party") saving(parties.gph, replace) // note("Note: 95% and 90% CIs shown", size(vsmall)) 
 



 graph export "AppendixFigureI1.png", replace
 
 
  erase parties.gph

 *** APPENDIX FIGURE J1
local controls "age male i.edu5cats i.region responseorder"

regress partylike i.treat_stack_v2 i.indic `controls', cluster(U0)
margins, dydx(treat_stack_v2) post
estimates store m0_like
regress partylike i.treat_stack_v2##i.indic  `controls', cluster(U0)
margins if party==1, dydx(treat_stack_v2) post
estimates store m1_like
regress partylike i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if party==2, dydx(treat_stack_v2) post
estimates store m2_like
regress partylike i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if party==3, dydx(treat_stack_v2) post
estimates store m3_like

regress partysocdist i.treat_stack_v2 i.indic   `controls' , cluster(U0)
margins, dydx(treat_stack_v2) post
estimates store m0_socdist
regress partysocdist i.treat_stack_v2##i.indic  `controls', cluster(U0)
margins if party==1, dydx(treat_stack_v2) post
estimates store m1_socdist
regress partysocdist i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if party==2, dydx(treat_stack_v2) post
estimates store m2_socdist
regress partysocdist i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if party==3, dydx(treat_stack_v2) post
estimates store m3_socdist

regress partylike_index i.treat_stack_v2 i.indic    `controls' , cluster(U0)
margins, dydx(treat_stack_v2) post
estimates store m0
sum partylike_index if e(sample)
regress partylike_index i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if party==1, dydx(treat_stack_v2) post
estimates store m1
regress partylike_index i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if party==2, dydx(treat_stack_v2) post
estimates store m2
regress partylike_index i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if party==3, dydx(treat_stack_v2) post
estimates store m3

sum partylike_index if e(sample)

 coefplot m0 m0_like m0_socdist, ///
xline(0, lcolor(red) lpattern(dot)) yline(0.85, lpattern(dash) lcolor(black) )  ///
mcolor(black) ciopts(color(gs6 black )) /// title("Effect of coalition signals on affective distance") 
levels(95 90) legend(off) msymbol(O) mcolor(black)  ///
xtitle("<<< less affective distance || more affective distance >>>", size(small)) ///
 ylabel(0.75 "Index" 1 "Like-Dislike" 1.25 "Social Distance") yscale(range(0.7 1.3)) ///
 scheme(plotplain) title("Overall effect") saving(overall.gph, replace) // note("Note: 95% and 90% CIs shown", size(vsmall)) 
 
  coefplot m1 m1_like m1_socdist m2 m2_like m2_socdist m3 m3_like m3_socdist, ///
xline(0, lcolor(red) lpattern(dot)) yline(0.85, lpattern(dash) lcolor(black) )  ///
 yline(1.15, lpattern(dash) lcolor(black) ) ///
mcolor(black) ciopts(color(gs6 black )) /// title("Effect of coalition signals on affective distance") 
levels(95 90) legend(off) msymbol(O) mcolor(black)  ///
xtitle("<<< less affective distance || more affective distance >>>", size(small)) ///
 ylabel(0.6 "Index" 0.7 "Like-Dislike" 0.8 "Social Distance"  ///
 0.9 "Index" 1 "Like-Dislike" 1.1 "Social Distance" ///
 1.2 "Index" 1.3 "Like-Dislike" 1.4 "Social Distance") yscale(range(0.5 1.5))  ///
 text(0.7 -1.3 "ÖVP") text(1 -1.3 "SPÖ") text(1.3 -1.3 "FPÖ") ///
 scheme(plotplain) title("Effect by coalition partner") saving(parties.gph, replace) // note("Note: 95% and 90% CIs shown", size(vsmall)) 
 
 graph combine overall.gph parties.gph, scheme(plotplain)

 graph export "AppendixFigureJ1.png", replace
 
 erase overall.gph
  erase parties.gph
  
  
  
  *** Appendix L: HTE BY SOPH; ID; DISTANCE
  local controls " responseorder"
regress partylike_index i.treat_stack_v2##c.idstrength_sum i.party `controls' , cl(U0)
margins, dydx(treat_stack_v2) at(idstrength_sum=(1 2 3)) post
estimates store m0

regress partylike_index i.treat_stack_v2##c.soph i.party `controls', cl(U0)
margins, dydx(treat_stack_v2) at(soph=(1.5 3 4.5)) post
estimates store m1

regress partylike_index i.treat_stack_v2##c.inpartydist i.party `controls', cl(U0)
margins, dydx(treat_stack_v2) at(inpartydist=(0 2 4)) post
estimates store m2

coefplot m0 m1 m2, ///
xline(0, lcolor(red) lpattern(dot)) yline(1.5, lpattern(dash) lcolor(black) )  ///
yline(2.5, lpattern(dash) lcolor(black) )  ///
 title("Effect of coalition signals on affective distance") levels(95 90) legend(off) msymbol(O) mcolor(black)  ///
xtitle("<<< less affective distance || more affective distance >>>", size(small)) ///
 ylabel(1 "Low" 2 "Medium" 3 "High") yscale(range(.5 3)) ///
 text(.83 -.3 "ID strength", size(small)) ///
 text(1.10 -.9 "Political Sophistication" , size(small)) ///
 text(1.33 -.2 "Distance from inparty", size(small))  ///
 note("Note: 95% and 90% CIs shown", size(vsmall)) ///
 scheme(plotplain)

 graph export "AppendixFigureL1.png", replace

  
  
  
*********************************
*** Appendix M:  Effect on inparty
 

cd "C:\Users\marku\Dropbox\AP Katrin Markus\replication"

use "prepared_data.dta", clear

keep if inpartyincluded==1
keep if party==idvotecat


 
local controls "responseorder"


regress partylike i.treat_stack_v2 i.idvotecat  `controls', cluster(U0)
margins, dydx(treat_stack_v2) post
estimates store m0_like
regress partylike i.treat_stack_v2##i.idvotecat  `controls', cluster(U0)
margins if idvotecat==1, dydx(treat_stack_v2) post
estimates store m1_like
regress partylike i.treat_stack_v2##i.idvotecat    `controls' , cluster(U0)
margins if idvotecat==2, dydx(treat_stack_v2) post
estimates store m2_like
regress partylike i.treat_stack_v2##i.idvotecat    `controls' , cluster(U0)
margins if idvotecat==3, dydx(treat_stack_v2) post
estimates store m3_like

regress partysocdist i.treat_stack_v2 i.idvotecat   `controls' , cluster(U0)
margins, dydx(treat_stack_v2) post
estimates store m0_socdist
regress partysocdist i.treat_stack_v2##i.idvotecat  `controls', cluster(U0)
margins if idvotecat==1, dydx(treat_stack_v2) post
estimates store m1_socdist
regress partysocdist i.treat_stack_v2##i.idvotecat    `controls' , cluster(U0)
margins if idvotecat==2, dydx(treat_stack_v2) post
estimates store m2_socdist
regress partysocdist i.treat_stack_v2##i.idvotecat    `controls' , cluster(U0)
margins if idvotecat==3, dydx(treat_stack_v2) post
estimates store m3_socdist

regress partylike_index i.treat_stack_v2 i.idvotecat    `controls' , cluster(U0)
margins, dydx(treat_stack_v2) post
estimates store m0
sum partylike_index if e(sample)
regress partylike_index i.treat_stack_v2##i.idvotecat    `controls' , cluster(U0)
margins if idvotecat==1, dydx(treat_stack_v2) post
estimates store m1
regress partylike_index i.treat_stack_v2##i.idvotecat    `controls' , cluster(U0)
margins if idvotecat==2, dydx(treat_stack_v2) post
estimates store m2
regress partylike_index i.treat_stack_v2##i.idvotecat    `controls' , cluster(U0)
margins if idvotecat==3, dydx(treat_stack_v2) post
estimates store m3

coefplot m0 m0_like m0_socdist, ///
xline(0, lcolor(red) lpattern(dot)) yline(0.85, lpattern(dash) lcolor(black) )  ///
mcolor(black) ciopts(color(gs6 black )) ///title("Effect of coalition signals on affective distance") 
levels(95 90) legend(off) msymbol(O) mcolor(black)  ///
xtitle("<<< less affective distance || more affective distance >>>", size(small)) ///
 ylabel(0.75 "Index" 1 "Like-Dislike" 1.25 "Social Distance") yscale(range(0.7 1.3)) ///
 scheme(plotplain) title("Overall effect") saving(overall.gph, replace) // note("Note: 95% and 90% CIs shown", size(vsmall)) 
 
  coefplot m1 m1_like m1_socdist m2 m2_like m2_socdist m3 m3_like m3_socdist, ///
xline(0, lcolor(red) lpattern(dot)) yline(0.85, lpattern(dash) lcolor(black) )  ///
 yline(1.15, lpattern(dash) lcolor(black) ) ///
mcolor(black) ciopts(color(gs6 black )) /// title("Effect of coalition signals on affective distance") 
levels(95 90) legend(off) msymbol(O) mcolor(black)  ///
xtitle("<<< less affective distance || more affective distance >>>", size(small)) ///
 ylabel(0.6 "Index" 0.7 "Like-Dislike" 0.8 "Social Distance"  ///
 0.9 "Index" 1 "Like-Dislike" 1.1 "Social Distance" ///
 1.2 "Index" 1.3 "Like-Dislike" 1.4 "Social Distance") yscale(range(0.5 1.5))  ///
 text(0.7 -1.3 "ÖVP") text(1 -1.3 "SPÖ") text(1.3 -1.3 "FPÖ") ///
 scheme(plotplain) title("Effect by in-party") saving(parties.gph, replace) // note("Note: 95% and 90% CIs shown", size(vsmall)) 
 
 graph combine overall.gph parties.gph, scheme(plotplain)

 graph export "AppendixFigureM1.png", replace

 
 ***** APPENDIX N
  
  cd "C:\Users\marku\Dropbox\AP Katrin Markus\replication"

use "prepared_data.dta", clear


keep if inpartyincluded==1
drop if party==idvotecat
drop if party==1&treat3==3 // drop ÖVP evaluation from SPÖ-FPÖ treatment
drop if party==2&treat3==2 // drop SPÖ evaluation from ÖVP-FPÖ treatment
drop if party==3&treat3==1 // drop FPÖ evaluation from SPÖ-ÖVP treatment

  
local controls "responseorder"

regress partyconv i.treat_stack_v2 i.indic    `controls' , cluster(U0)
margins, dydx(treat_stack_v2) post
estimates store m4
sum partydist if e(sample)
regress partyconv i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if party==1, dydx(treat_stack_v2) post
estimates store m4a
regress partyconv i.treat_stack_v2##i.indic    `controls' , cluster(U0)
margins if party==2, dydx(treat_stack_v2) post
estimates store m4b
regress partyconv i.treat_stack_v2##i.indic   `controls' , cluster(U0)
margins if party==3, dydx(treat_stack_v2) post
estimates store m4c

coefplot m4 m4a m4b m4c, ///
xline(0, lcolor(red) lpattern(dot)) yline(0.8, lpattern(dash) lcolor(black) ) mcolor(black) ciopts(color(gs6 black )) /// ///
/// title("Effect of coalition signals on affective distance") 
levels(95 90) legend(off) msymbol(O) mcolor(black)  ///
xtitle("<<< less left-right distance || more left-right distance >>>", size(small)) ///
 ylabel(0.7 "Overall" 0.9 "ÖVP" 1.1 "SPÖ" 1.3 "FPÖ") yscale(range(0.6 1.4)) ///
 scheme(plotplain) // note("Note: 95% and 90% CIs shown", size(vsmall)) 
 
  graph export "AppendixFigureN1.png", replace

 
 
   **** Appendix P: MEDIATION BY SOPHISTICATION

   
  
  
  
  *** Low sophistication
  tab indic, gen(indicat)

 local controls "indicat2 indicat3 indicat4 indicat5 indicat6 responseorder"


medeff (regress partyconv treat_stack_v2 `controls') (regress partylike_index treat_stack_v2  partyconv  `controls') if soph<=2, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345)  
matrix r1= r(delta0), r(delta0lo), r(delta0hi) 

medeff (regress partyconv treat_stack_v2 `controls') (regress partylike_index treat_stack_v2  partyconv  `controls') if soph<=2, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) level(90) 
matrix r1= r1, r(delta0lo), r(delta0hi) 


medeff (regress partyconv treat_stack_v2 `controls') (regress partylike treat_stack_v2  partyconv  `controls') if soph<=2, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) 
matrix r2= r(delta0), r(delta0lo), r(delta0hi) 
medeff (regress partyconv treat_stack_v2 `controls') (regress partylike treat_stack_v2  partyconv  `controls')if soph<=2 , vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) level(90) 
matrix r2= r2, r(delta0lo), r(delta0hi) 



medeff (regress partyconv treat_stack_v2 `controls') (regress partysocdist treat_stack_v2  partyconv  `controls') if soph<=2, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) 
matrix r3= r(delta0), r(delta0lo), r(delta0hi) 

medeff (regress partyconv treat_stack_v2 `controls') (regress partysocdist treat_stack_v2  partyconv  `controls') if soph<=2, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) level(90) 
matrix r3= r3, r(delta0lo), r(delta0hi) 

 

matrix r=r1\r2\r3
svmat r
gen index=_n if _n<=3
graph twoway (scatter  index r1 if index<4, msymbol(S) msize(medium) mcolor(black)) (rcap  r2 r3 index  if index<4, horizontal lcolor(gs6) lwidth(thin)) (rcap  r4 r5 index  if index<4, horizontal lcolor(black) lwidth(medthick)), scheme(plotplain) ///
legend(off) ytitle("Effect of coalition signals mediated by distance") ylabel(1 "ACME, Index" 2 "ACME, Like-Dislike" 3 "ACME, Social Distance") yscale(reverse) ///
xline(0, lpattern(dash) )  xscale(range(-.2 .15)) xlabel(-.2(.05).2) ///
yline(1.5, lpattern(dash) lwidth( medthick )) title("Low sophistication") ///
yscale(range(0.5 3.5)) saving(lowsoph.gph, replace)
 ///yline(5.5, lpattern(dot)) 
/// title("ACME from mediation analyses") 
//note("Note:Figure shows average conditional mediated effect of coalition signals "" on affective distance via reduced left-right distance; 95% confidence intervals shown", size(vsmall))
 
 drop r1-r5 index
 
  local controls "indicat2 indicat3 indicat4 indicat5 indicat6 responseorder"


medeff (regress partyconv treat_stack_v2 `controls') (regress partylike_index treat_stack_v2  partyconv  `controls') if soph>2, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345)  
matrix r1= r(delta0), r(delta0lo), r(delta0hi) 

medeff (regress partyconv treat_stack_v2 `controls') (regress partylike_index treat_stack_v2  partyconv  `controls') if soph>2, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) level(90) 
matrix r1= r1, r(delta0lo), r(delta0hi) 


medeff (regress partyconv treat_stack_v2 `controls') (regress partylike treat_stack_v2  partyconv  `controls') if soph>2, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) 
matrix r2= r(delta0), r(delta0lo), r(delta0hi) 
medeff (regress partyconv treat_stack_v2 `controls') (regress partylike treat_stack_v2  partyconv  `controls')if soph>2 , vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) level(90) 
matrix r2= r2, r(delta0lo), r(delta0hi) 



medeff (regress partyconv treat_stack_v2 `controls') (regress partysocdist treat_stack_v2  partyconv  `controls') if soph>2, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) 
matrix r3= r(delta0), r(delta0lo), r(delta0hi) 

medeff (regress partyconv treat_stack_v2 `controls') (regress partysocdist treat_stack_v2  partyconv  `controls') if soph>2, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) level(90) 
matrix r3= r3, r(delta0lo), r(delta0hi) 

 

matrix r=r1\r2\r3
svmat r
gen index=_n if _n<=3
graph twoway (scatter  index r1 if index<4, msymbol(S) msize(medium) mcolor(black)) (rcap  r2 r3 index  if index<4, horizontal lcolor(gs6) lwidth(thin)) (rcap  r4 r5 index  if index<4, horizontal lcolor(black) lwidth(medthick)), scheme(plotplain) ///
legend(off) ytitle("Effect of coalition signals mediated by distance") ylabel(1 "ACME, Index" 2 "ACME, Like-Dislike" 3 "ACME, Social Distance") yscale(reverse) ///
xline(0, lpattern(dash) )  xscale(range(-.2 .15)) xlabel(-.2(.05).2) ///
yline(1.5, lpattern(dash) lwidth( medthick )) title("High sophistication") ///
yscale(range(0.5 3.5)) saving(highsoph.gph, replace)
 ///yline(5.5, lpattern(dot)) 
/// title("ACME from mediation analyses") 
//note("Note:Figure shows average conditional mediated effect of coalition signals "" on affective distance via reduced left-right distance; 95% confidence intervals shown", size(vsmall))
 
 graph combine lowsoph.gph highsoph.gph, scheme(plotplain)
 
 
 
 graph export "AppendixFigureP1.png", replace
 
 erase lowsoph.gph
 erase highsoph.gph
drop r1-r5 index


  **** APPENDIX P: MEDIATION BY Response order

   
  
  
  *** Affect first


 local controls "indicat2 indicat3 indicat4 indicat5 indicat6 "


medeff (regress partyconv treat_stack_v2 `controls') (regress partylike_index treat_stack_v2  partyconv  `controls') if responseorder==0, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345)  
matrix r1= r(delta0), r(delta0lo), r(delta0hi) 

medeff (regress partyconv treat_stack_v2 `controls') (regress partylike_index treat_stack_v2  partyconv  `controls') if responseorder==0, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) level(90) 
matrix r1= r1, r(delta0lo), r(delta0hi) 


medeff (regress partyconv treat_stack_v2 `controls') (regress partylike treat_stack_v2  partyconv  `controls') if responseorder==0, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) 
matrix r2= r(delta0), r(delta0lo), r(delta0hi) 
medeff (regress partyconv treat_stack_v2 `controls') (regress partylike treat_stack_v2  partyconv  `controls')if responseorder==0 , vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) level(90) 
matrix r2= r2, r(delta0lo), r(delta0hi) 



medeff (regress partyconv treat_stack_v2 `controls') (regress partysocdist treat_stack_v2  partyconv  `controls') if responseorder==0, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) 
matrix r3= r(delta0), r(delta0lo), r(delta0hi) 

medeff (regress partyconv treat_stack_v2 `controls') (regress partysocdist treat_stack_v2  partyconv  `controls') if responseorder==0, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) level(90) 
matrix r3= r3, r(delta0lo), r(delta0hi) 

 

matrix r=r1\r2\r3
svmat r
gen index=_n if _n<=3
graph twoway (scatter  index r1 if index<4, msymbol(S) msize(medium) mcolor(black)) (rcap  r2 r3 index  if index<4, horizontal lcolor(gs6) lwidth(thin)) (rcap  r4 r5 index  if index<4, horizontal lcolor(black) lwidth(medthick)), scheme(plotplain) ///
legend(off) ytitle("Effect of coalition signals mediated by distance") ylabel(1 "ACME, Index" 2 "ACME, Like-Dislike" 3 "ACME, Social Distance") yscale(reverse) ///
xline(0, lpattern(dash) )  xscale(range(-.2 .15)) xlabel(-.2(.05).2) ///
yline(1.5, lpattern(dash) lwidth( medthick )) title("Affect first") ///
yscale(range(0.5 3.5)) saving(affect.gph, replace)
 ///yline(5.5, lpattern(dot)) 
/// title("ACME from mediation analyses") 
//note("Note:Figure shows average conditional mediated effect of coalition signals "" on affective distance via reduced left-right distance; 95% confidence intervals shown", size(vsmall))
 
 drop r1-r5 index
 
 
  *** Positions first
  local controls "indicat2 indicat3 indicat4 indicat5 indicat6 "


medeff (regress partyconv treat_stack_v2 `controls') (regress partylike_index treat_stack_v2  partyconv  `controls') if responseorder==1, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345)  
matrix r1= r(delta0), r(delta0lo), r(delta0hi) 

medeff (regress partyconv treat_stack_v2 `controls') (regress partylike_index treat_stack_v2  partyconv  `controls') if responseorder==1, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) level(90) 
matrix r1= r1, r(delta0lo), r(delta0hi) 


medeff (regress partyconv treat_stack_v2 `controls') (regress partylike treat_stack_v2  partyconv  `controls') if responseorder==1, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) 
matrix r2= r(delta0), r(delta0lo), r(delta0hi) 
medeff (regress partyconv treat_stack_v2 `controls') (regress partylike treat_stack_v2  partyconv  `controls')if responseorder==1 , vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) level(90) 
matrix r2= r2, r(delta0lo), r(delta0hi) 



medeff (regress partyconv treat_stack_v2 `controls') (regress partysocdist treat_stack_v2  partyconv  `controls') if responseorder==1, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) 
matrix r3= r(delta0), r(delta0lo), r(delta0hi) 

medeff (regress partyconv treat_stack_v2 `controls') (regress partysocdist treat_stack_v2  partyconv  `controls') if responseorder==1, vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) level(90) 
matrix r3= r3, r(delta0lo), r(delta0hi) 

 

matrix r=r1\r2\r3
svmat r
gen index=_n if _n<=3
graph twoway (scatter  index r1 if index<4, msymbol(S) msize(medium) mcolor(black)) (rcap  r2 r3 index  if index<4, horizontal lcolor(gs6) lwidth(thin)) (rcap  r4 r5 index  if index<4, horizontal lcolor(black) lwidth(medthick)), scheme(plotplain) ///
legend(off) ytitle("Effect of coalition signals mediated by distance") ylabel(1 "ACME, Index" 2 "ACME, Like-Dislike" 3 "ACME, Social Distance") yscale(reverse) ///
xline(0, lpattern(dash) )  xscale(range(-.2 .15)) xlabel(-.2(.05).2) ///
yline(1.5, lpattern(dash) lwidth( medthick )) title("Left-right first") ///
yscale(range(0.5 3.5)) saving(positions.gph, replace)
 ///yline(5.5, lpattern(dot)) 
/// title("ACME from mediation analyses") 
//note("Note:Figure shows average conditional mediated effect of coalition signals "" on affective distance via reduced left-right distance; 95% confidence intervals shown", size(vsmall))
 
 graph combine affect.gph positions.gph, scheme(plotplain)
 
 
 
 graph export "AppendixFigureP2.png", replace
 
 erase affect.gph
 erase positions.gph
drop r1-r5 index


log close